Skip to content

refactor: Upgrade agent-framework and azure-ai-projects libraries with API changes#927

Draft
Harsh-Microsoft wants to merge 2 commits into
devfrom
psl-hb-us-43549
Draft

refactor: Upgrade agent-framework and azure-ai-projects libraries with API changes#927
Harsh-Microsoft wants to merge 2 commits into
devfrom
psl-hb-us-43549

Conversation

@Harsh-Microsoft
Copy link
Copy Markdown
Contributor

@Harsh-Microsoft Harsh-Microsoft commented May 22, 2026

Purpose

This pull request upgrades the agent framework and related Azure AI dependencies to their latest GA (General Availability) versions, and refactors the codebase to use the new FoundryAgent API instead of the deprecated AzureAIProjectAgentProvider. Additionally, it introduces a runtime patch to restore per-document URL enrichment for Azure AI Search citations, addressing a regression in the latest agent framework. The changes also update logging configuration and clean up requirements files to remove deprecated packages.

Dependency and API upgrades:

  • Upgraded azure-ai-projects, replaced azure-ai-agents and agent-framework-azure-ai with agent-framework-foundry, and updated all relevant requirements files to use GA versions of agent framework and Azure AI packages. (infra/scripts/agent_scripts/requirements.txt, infra/scripts/index_scripts/requirements.txt, src/api/requirements.txt) [1] [2] [3]

Agent API refactoring:

  • Refactored all usages of AzureAIProjectAgentProvider to use the new FoundryAgent API for agent creation and management in both agent and index scripts, as well as in service layers. (infra/scripts/agent_scripts/01_create_agents.py, infra/scripts/index_scripts/03_cu_process_data_text.py, infra/scripts/index_scripts/04_cu_process_custom_data.py, src/api/services/chat_service.py, src/api/services/history_service.py) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Azure AI Search citation enrichment patch:

  • Added a runtime patch to agent_framework_openai to restore per-document URL enrichment (get_url) for streaming Azure AI Search citations, working around a known regression in the GA release. This ensures downstream code receives the expected citation URLs. (src/api/services/_patches/agent_framework_search_citations.py, src/api/services/_patches/__init__.py, src/api/services/chat_service.py) [1] [2] [3] [4]

Logging and import updates:

  • Updated logging to target the new agent_framework.foundry logger instead of the deprecated agent_framework.azure, and adjusted imports throughout the codebase to match new package structure. (infra/scripts/index_scripts/03_cu_process_data_text.py, infra/scripts/index_scripts/04_cu_process_custom_data.py, src/api/services/chat_service.py) [1] [2] [3]

Other notable improvements:

  • Updated agent instantiation to properly handle session management with AgentSession and improved citation extraction logic to prefer the patched per-document URL. (src/api/services/chat_service.py) [1] [2]

Does this introduce a breaking change?

  • Yes
  • No

Golden Path Validation

  • I have tested the primary workflows (the "golden path") to ensure they function correctly without errors.

Deployment Validation

  • I have validated the deployment process successfully and all services are running as expected with this change.

What to Check

Verify that the following are valid

  • ...

Other Information

Harsh-Microsoft and others added 2 commits May 21, 2026 21:03
Library upgrades (US #43549):
- agent-framework-core: 1.0.0rc2 -> 1.3.0
- azure-ai-projects: 2.0.0b3 -> 2.1.0
- Replace retired agent-framework-azure-ai/azure-ai-agents with
  agent-framework-foundry==1.3.0 and azure-ai-inference==1.0.0b9

Code changes for the new GA API surface:
- chat_service / history_service: switch from AzureAIProjectAgentProvider
  to FoundryAgent and use AgentSession(service_session_id=...) in place of
  the removed conversation_id streaming kwarg.
- infra agent/index scripts: align with the new SDK imports and GA APIs.

Citation regression workaround (microsoft/agent-framework#5995):
- Add services/_patches/agent_framework_search_citations.py, a runtime
  monkey-patch of RawOpenAIChatClient._parse_chunk_from_openai that
  re-attaches per-document REST URLs (additional_properties.get_url) on
  Azure AI Search url_citation annotations. Mapping uses the doc index
  parsed from the citation title (doc_<N>) so duplicate citations resolve
  correctly. Patch is idempotent and degrades gracefully if upstream
  fixes the regression or renames the target method.
- chat_service citation extraction now prefers additional_properties.get_url
  over the search-service root url so titles/links are per-document.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The services/_patches/agent_framework_search_citations.py monkey-patch
targets internals of agent_framework_openai, so pin its version
explicitly instead of relying on transitive resolution via
agent-framework-foundry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
src/api/services
   chat_service.py1751293%64–65, 236–239, 243, 246, 257–258, 278–279
   history_service.py2052488%90, 221–222, 224, 261–263, 279, 285–287, 304, 320–321, 323, 339, 365–366, 368, 384, 404–405, 407, 426
src/api/services/_patches
   __init__.py00100% 
   agent_framework_search_citations.py876426%54, 58–59, 63, 67, 73, 78, 82–83, 88–96, 98–112, 117, 121–131, 134–135, 140–149, 155–160, 162
TOTAL140321684% 

Tests Skipped Failures Errors Time
163 0 💤 0 ❌ 0 🔥 5.291s ⏱️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant